import java.util.Random;
public class Main {
    public static void main(String[] args) {
        int[] arr = {2,4,3,5,7,9,1,6,8,10};
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if(arr[j] > arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j + 1] = tmp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
    public static void main3(String[] args) {
        int [][] arr = new int[9][9];
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <=9 ; j++) {
                arr[i][j]= i * j;
            }

        }
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <=i ; j++) {
                System.out.printf("%d * %d = %d   " ,i , j , arr[i][j] );
            }
            System.out.println();
        }
    }

    public static void main2(String[] args) {
        int[][] arr=new int[4][4];
        Random num = new Random();
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                int rand = num.nextInt(100);
                arr[i][j]= rand;
            }
        }
        for (int i = 0; i < 4; i++) {
            int j = 0;
            for ( j = 0; j < 4; j++) {
                System.out.printf("%-2d    ",arr[i][j]);
            }
            if ( j == 4) {
                System.out.println();
            }
        }
        int  z = 0,k=0;
        int max =arr[0][0];
        for (int i = 1; i < 4; i++) {
            for (int j = i; j == i; j++) {
                if(max<arr[i][j]){
                    max = arr[i][j];
                    z = i;
                    k = j;
                }
            }
        }
        System.out.println("最大值为：" + max);
        System.out.println("位置为：" + z + "," + k);
    }

    public static void main1(String[] args) {
        int[] arr=new int[20];
        Random num = new Random();
        int i = 0;
        for( i = 0;i < 20 ;i++) {
            int rand = num.nextInt(100);
            arr[i] = rand;
        }
        long sum =0;
        int j =0;
        for( j = 0;j<20 ; j++) {
            sum+=arr[j];
        }
        System.out.println(sum/20);
    }
}